package cn.radonline.ftp;

import cn.hutool.extra.ftp.Ftp;
import org.apache.commons.net.ftp.FTPFile;

import java.io.File;
import java.io.IOException;

public class FtpTester {
    public static void main(String[] args) {
        System.out.println("ftp test is starting !!!!");
        Ftp ftp = new Ftp("192.168.136.1", 21, "ftpuser", "panpan");
        System.out.println("ftp test 连接ftp服务器成功 !!!!");
        FTPFile[] ff = ftp.lsFiles("/");

        for (int i = 0; i < ff.length; i++) {

            ftp.download("/" + ff[i].getName(), new File("tmp/ftp/" + ff[i].getName()));
            System.out.println(i + "下载ftp成功," + ff[i].getName());
        }

        try {
            ftp.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
